package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 风险等级
 *
 * @author ytche
 * @date 2017年8月2日
 *
 */
@Entity
@JsonApiResource(type = "riskLevel")
@Table(name = "TNB_RISK_LEVEL")
public class RiskLevel extends BaseEntity {
	private static final long serialVersionUID = 1L;
	private String remark;
	private Integer level;
	private String levelName;
	private RiskAssessModel assess;
	private Integer minScore;
	private Integer maxScore;
	private Set<CustomerServiceItem> serviceItem;

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "level")
	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	@Column(name = "level_name")
	public String getLevelName() {
		return levelName;
	}

	public void setLevelName(String levelName) {
		this.levelName = levelName;
	}

	@Column(name = "min_score")
	public Integer getMinScore() {
		return minScore;
	}

	public void setMinScore(Integer minScore) {
		this.minScore = minScore;
	}

	@Column(name = "max_score")
	public Integer getMaxScore() {
		return maxScore;
	}

	public void setMaxScore(Integer maxScore) {
		this.maxScore = maxScore;
	}

	@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinTable(name = "TNB_REL_RISK_LEVEL_SERVICE", joinColumns = { @JoinColumn(name = "level_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "service_id", nullable = false, updatable = false) })
	@JsonApiToMany
	@JsonApiIncludeByDefault
	public Set<CustomerServiceItem> getServiceItem() {
		return serviceItem;
	}

	public void setServiceItem(Set<CustomerServiceItem> serviceItem) {
		this.serviceItem = serviceItem;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.SELECT)
	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	@JoinColumn(name = "risk_assess_id")
	public RiskAssessModel getAssess() {
		return assess;
	}

	public void setAssess(RiskAssessModel assess) {
		this.assess = assess;
	}
}
